<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head th:replace="components/head :: head(~{:: title}, ~{:: link})">
    <title>文章编辑</title>
    <link rel="stylesheet" th:href="@{/css/wen.css}">
    <link rel="stylesheet" href="/editor-md/css/editormd.min.css"/>
</head>
<body>
<!-- Header -->
<div th:replace="components/navbar_and_head :: navbarAndHeader"></div>
<!-- End Header -->

<div class="container-fluid">
    <div class="alert alert-danger" role="alert"
         th:if="${errInfo != null}" th:text="${errInfo}"></div>
    <form th:action="${article.id == null} ? '/admin/article/add' : '/admin/article/edit/' + ${article.id}"
          method="post">
        <div class="row">
            <div class="form-group col-md-8 col-md-offset-2">
                <label for="title">文章标题</label>
                <input th:value="${article.title}" id="title" name="title" placeholder="文章标题" class="form-control">
            </div>
        </div>
        <div id="editor">
            <!-- Tips: Editor.md can auto append a `<textarea>` tag -->
            <textarea th:text="${article.content}" wrap="hard" cols="100" name="content" id="content"></textarea>
        </div>

        <div class="row">
            <div class="col-md-8 col-md-offset-2">
                <div class="form-group">
                    <label for="type">文章类型</label>
                    <input th:value="${type}" id="type" name="type" placeholder="文章类型" class="form-control">
                </div>
                <div class="form-group">
                    <label for="tag">文章标签</label>
                    <input th:value="${tags}" id="tag" name="tag" placeholder="文章标签" class="form-control">
                </div>
                <input class="btn btn-default" type="submit" value="Submit">
            </div>
        </div>
    </form>
</div>

<!-- Footer -->
<div th:replace="components/footer :: footer"></div>
<!-- End Footer -->


<script th:src="@{/editor-md/editormd.min.js}"></script>
<script type="text/javascript">
    $(function () {
        var editor = editormd("editor", {
            width: "90%",
            height: "800px",
            // markdown: "xxxx",     // dynamic set Markdown text
            path: "/editor-md/lib/"  // Autoload modules mode, codemirror, marked... dependents libs path
        });
    });
</script>
</body>
</html>